package com.sqf.controller;

import com.github.pagehelper.PageInfo;
import com.sqf.entity.Goods;
import com.sqf.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
public class GoodsController {
    @Autowired
    GoodsService goodsService;

    @RequestMapping("list")
    public PageInfo<Goods> list(Goods goods, Integer pageNo, Integer pageSize){

        PageInfo<Goods> list = goodsService.list(goods, pageNo, pageSize);
        return list;
    }

    @RequestMapping("list1")
    public List<Goods> list1(){

        List<Goods> goods = goodsService.list1();
        return goods;
    }

    @RequestMapping("delete")
    public boolean delete(Integer id){
        boolean b = goodsService.delete(id);
        return b;
    }

    @RequestMapping("byid")
    public Goods byid(Integer id){
        Goods byid = goodsService.Byid(id);
        return byid;
    }

}
